package org.xhy.aop.core;

import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @description: 封装可执行的目标方法数据
 * @gitee: https://gitee.com/XhyQAQ
 * @copyright: B站: https://space.bilibili.com/152686439
 * @Author: Xhy
 * @CreateTime: 2024-01-13 23:36
 */
public class ProceedingJoinPoint extends JoinPoint{


    private final Object targetObject;

    private final MethodProxy methodProxy;

    public ProceedingJoinPoint(Object targetObject, MethodProxy methodProxy,Method method, Object[] args ) {
        super(method,args);
        this.targetObject = targetObject;
        this.methodProxy = methodProxy;
    }

    @Override
    public Object invoke() throws Throwable {
        return methodProxy.invokeSuper(targetObject, getArgs());
    }

    @Override
    public Object invoke(Object[] args) throws Throwable {
        return methodProxy.invokeSuper(targetObject, args);
    }
}
